package com.boot.main.controller;

import com.boot.main.entity.ScomAd;
import com.boot.main.entity.ScomCategory;
import com.boot.main.service.IAdService;
import com.boot.main.service.ICategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/api")
@Api(tags = "分类管理")
public class CategoryController {
    @Resource
    private ICategoryService categoryService;

    @RequestMapping(value="/categorys", method = RequestMethod.GET)
    @ApiOperation(value="获取分类列表")
    public Object getCategorys(){
        return categoryService.getCategorys();
    }

    @RequestMapping(value="/category/{status}", method = RequestMethod.GET)
    @ApiOperation(value = "获取推荐分类")
    public Object getCategoryByStatus(@PathVariable("status") Integer status){
        return categoryService.getCategoryByStatus(status);
    }

    @RequestMapping(value="/category", method = RequestMethod.POST)
    @ApiOperation(value="新增分类")
    public Object saveCategory(@RequestBody ScomCategory category){
        return categoryService.saveCategory(category);
    }

    @RequestMapping(value="/category/{id}", method = RequestMethod.PUT)
    @ApiOperation(value="修改分类")
    public Object updateCategory(@RequestBody ScomCategory category){
        return categoryService.updateCategory(category);
    }

    @RequestMapping(value="/category/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除分类")
    public Object deleteCategory(@PathVariable Long id){
        return categoryService.deleteCategory(id);
    }
}
